import {assert} from 'chai';
import { extractQuestions, calculateQuestion, fixRound } from '../src/utils';

describe('utils', () => {
  it('extractQuestions', () => {
    const source = `0.89×100.1          146.5－(23＋46.5)
3.83×4.56＋3.83×5.44      4.36×12.5×8      9.7×99＋9.7
27.5×3.7－7.5×3.7         8.54÷2.5÷0.4          0.65×101   3.2×0.25×12.5       (45.9－32.7)÷8÷0.125        3.14×0.68＋31.4×0.032
 5.6÷1.25÷0.8÷2.5÷0.4          7.2×0.2＋2.4×1.4
8.9×1.01              7.74×（2.8－1.3）＋1.5×2.26
3.9×2.7＋3.9×7.3         18－1.8÷0.125÷0.8          12.7×9.9＋1.27
21×（9.3－3.7）－5.6        15.02-6.8-1.02            5.4×11-5.4
2.3×16+2.3×23+2.3         9.43-（6.28-1.57）        3.65×4.7－36.5×0.37
46×57＋23×86            13.7×0.25－3.7÷4           2.22×9.9+6.66×6.7
101×0.87-0.91×87          10.7×16.1-15.1×10.7            0.79×199
4.8+8.63+5.2+0.37           5.93+0.19+2.81            1.76+0.195+3.24
2.35+1.713+0.287+7.65         1.57+0.245+7.43          6.02+3.6+1.98
0.134+2.66+0.866            1.27+3.9+0.73+16.1          7.5＋4.9－6.5
3.07－0.38－1.62            1.29＋3.7＋2.71＋6.3         8－2.45－1.55
3.25＋1.79－0.59＋1.75          23.4－0.8－13.4－7.2         0.32×403
3.2＋0.36＋4.8＋1.64            1.23＋3.4－0.23＋6.6          0.25×36
12.7－（3.7＋0.84）           36.54－1.76－4.54            0.25×0.73×4
7.6×0.8＋0.2×7.6              0.85×199                   0.25×8.5×4
1.28×8.6＋0.72×8.6            12.5×0.96×0.8            10.4－9.6×0.35
`;
    console.log(extractQuestions(source));
  });
  
  it('calculateQuestion', () => {
    const source = '0.89×100.1';
  
    calculateQuestion(source)
  });
  
  it('fixRound', () => {
    assert.equal(fixRound('1.420000'), '1.42');
    assert.equal(fixRound('37000'), '37000');
    assert.equal(fixRound('1.872123'), '1.872123');
    assert.equal(fixRound('1.21300'), '1.213');
    assert.equal(fixRound('4.00000000'), '4');
    assert.equal(fixRound('0.06000000'), '0.06');
  });
});